#include <iostream>
#include <memory>
using namespace std;
class person{
    public:
    string name;
    person(string m_name):name(m_name){}
    void show(){
        cout<<"person类对象"<<endl;
        cout<<"name="<<name<<endl;
    }
};
template<class T>
class deleteclass{
    public:
    void operator()(T *t){
        cout<<"仿函数删除器"<<endl;
        delete t;
    }
};
template<typename T>
void deletefun(T *t){
    cout<<"函数删除器"<<endl;
    delete t;
}
int main()
{
    //给shared_ptr指针分配删除器
    shared_ptr<person> pu1(new person("zhangsan"),deletefun<person>);//函数删除器
    shared_ptr<person> pu2(new person("lisi"),deleteclass<person>());//仿函数删除器

    //给unique_ptr指针分配删除器
    unique_ptr<person,decltype(deletefun<person>)*> pu3(new person("张三"),deletefun<person>);//使用decltype推断分配器的类型
    unique_ptr<person,void(*)(person*)> pu4(new person("wangwu"),deletefun<person>);//使用函数指针做unique_ptr的删除器
    return 0;
}